home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Screenblankers
/
XSB
/
gtlib.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-26
|
2KB
|
134 lines
/*
gadtools support lib
*/
#include "startup.h"
static struct VisualInfo *vi;
static struct Gadget *glist,*lastg,*gads[32];
static int gid;
struct TextAttr textattr={"topaz.font",8,0,0};
#define top80 textattr
void gt_init(void)
{
struct Screen *scr;
scr=LockPubScreen(0);
vi=GetVisualInfo(scr,TAG_DONE);
UnlockPubScreen(0,scr);
}
void gt_exit(void)
{
if(vi) FreeVisualInfo(vi);
}
struct Gadget *gt_newlist(void)
{
glist=0;gid=1;
lastg=CreateContext(&glist);
return(lastg);
}
void gt_endlist(void)
{
AddGList(w,glist,-1,-1,0);
RefreshGList(glist,w,0,-1);
GT_RefreshWindow(w,0);
}
void gt_remlist(struct Gadget *list)
{
FreeGadgets(list);
}
struct Gadget * __stdargs gt_createg(int x,int y,int xs,int ys,long type,char *label,int flags,...)
{
struct NewGadget ng;
ng.ng_LeftEdge=x; ng.ng_TopEdge=y;
ng.ng_Width=xs; ng.ng_Height=ys;
ng.ng_GadgetText=label;
ng.ng_GadgetID=gid++;
ng.ng_TextAttr=&top80;
ng.ng_Flags=flags;
ng.ng_VisualInfo=vi;
ng.ng_UserData=(APTR)0xaffe;
return(lastg=gads[gid-2]=CreateGadgetA(type,lastg,&ng,((long)(&flags))+4));
}
void gt_setg(struct Gadget *g,...)
{
GT_SetGadgetAttrsA(g,w,0,((long)(&g))+4);
}
void gt_drawbox(int x,int y,int size,int height,int typ)
{
DrawBevelBox(rp,x,y,size,height,(typ)?TAG_IGNORE:GTBB_Recessed,0,GT_VisualInfo,vi,TAG_DONE);
}
/*struct Menu *gt_createmenus(struct NewMenu *nm)
{
struct Menu *m;
m=CreateMenus(nm,GTMN_FrontPen,0,TAG_DONE);
if(m) {
if(LayoutMenus(m,vi,GTMN_TextAttr,&top80,TAG_DONE)) return(m);
FreeMenus(m);
}
return(0);
}*/
int doreq(char *hail,char *txt,char *gads,...)
{
struct EasyStruct es;
es.es_StructSize=sizeof(struct EasyStruct);
es.es_Flags=0;
es.es_Title=hail;
es.es_TextFormat=txt;
es.es_GadgetFormat=gads;
return(EasyRequestArgs(w,&es,0,((long)&gads)+4));
}
void text(int x,int y,char *txt)
{
Move(rp,x,y);
Text(rp,txt,strlen(txt));
}
void textf(int x,int y,char *txt,...)
{
char p[128];
_dofmt(txt,((long)&txt)+4,p);
Move(rp,x,y);
Text(rp,&p[0],strlen(&p[0]));
}
struct Gadget *gt_findid(short id)
{
if(!id) return(0);
return(gads[id-1]);
}
char *gt_findstring(short id)
{
struct StringInfo *si=gt_findid(id)->SpecialInfo;
return(si->Buffer);
}
long gt_findint(short id)
{
struct StringInfo *si=gt_findid(id)->SpecialInfo;
return(si->LongInt);
}
int gt_findstate(short id)
{
return(gt_findid(id)->Flags&SELECTED);
}